<template>
  <div class="news-list bg-c-fff pb70">
    <div class="news-banner rel">
      <div class="abs ban-news">
        <div class="container">
          <a href="">早报：P2P用银行卡突破限额 众安保险赴港上市</a>
        </div>
      </div>
    </div>
    <div class="fix container pt30">
      <ul class="notice-list">
        <li class="fix cup fix" v-for="item in noticeList" @click="onNoyiceDetail(item.id)">
          <h2 class="flo-left">{{item.title}}</h2>
          <span class="flo-right">{{item.createTime}}</span>
        </li>
      </ul>
      <button class="more auto db" @click="more">{{moreText}}</button>
    </div>
  </div>
</template>
<script type="text/javascript">
export default {
  data() {
    return {
      noticeList: [],
      page: 1,
      moreText: '加载更多'
    }
  },
  mounted() {
    console.log(this.$route.query.page)
    this.getNewData(1)
  },
  methods: {
    getNewData() {
      var parms = {
        page: this.page,
        rows: 2,
        type: 1
      }
      this.$http.get('/sysContent/list', {
        params: parms
      }).then(data => {
        if (data.data.httpCode === 200) {
          if (data.data.rows.length > 0) {
            data.data.rows.forEach((i) => {
              this.noticeList.push(i)
            })
          } else {
            this.moreText = '没有更多了'
          }
        } else {
          console.log(data.data.msg)
          this.$toasted.show(data.data.msg)
        }
      }).catch(err => {
        console.log(err)
      })
    },
    more() {
      this.page += 1
      this.getNewData()
    },
    onNoyiceDetail(id) {
      this.$router.push('/notice-text?id=' + id)
    }
  }
}

</script>
<style type="text/css" scoped>
.news-banner {
  width: 100%;
  height: 300px;
  background: url(../assets/about-banner.jpg) no-repeat center;
  background-size: cover;
}

.ban-news {
  background: rgba(0, 0, 0, 0.5);
  bottom: 0;
  line-height: 50px;
  font-size: 20px;
  font-weight: bold;
  width: 100%;
  min-width: 1200px;
}

.ban-news a {
  color: #fff;
}

.pt30 {
  padding-top: 30px;
}

.notice-list li {
  padding: 20px 0;
  border-bottom: 1px solid #ddd;
}

.notice-list li h2 {
  width: 70%;
}

.more {
  font-size: 16px;
  color: #282828;
  margin-top: 30px;
}

</style>
